package by.jtraining.london.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import by.jtraining.london.model.Lector;
import by.jtraining.london.repo.LectorRepository;
import by.jtraining.london.service.LectorService;

import com.google.inject.Inject;
import com.google.inject.persist.Transactional;

public class LectorServiceImpl extends
		GenericServiceImpl<Lector, Long, LectorRepository> implements
		LectorService {
	private static final Logger LOG = LoggerFactory
				.getLogger(LectorServiceImpl.class);
	@Inject
	public LectorServiceImpl(LectorRepository lectorRepository) {
		super(lectorRepository);
	}

	@Transactional
	@Override
	public void add(Lector lector) {
		LOG.debug("Trying to add lector{}", lector);
		repo.add(lector);
		LOG.debug("Added lector: {}", lector);
	}
	
	@Transactional
	@Override
	public List<Lector> getAllLectors(){
		LOG.debug("Trying to get all lector!");
		return repo.getLectorsSortedByActive();
	}
	
	@Transactional
	@Override
	public void reverseIsActiveForLector(long id){
		LOG.debug("Trying to reverse state isActive for Lector");
		repo.reverseIsActiveForLector(id);
		LOG.debug("reverse state isActive for Lector");
	}
}
